package nl.vu.few.ibivu.biomodels.client.activity;

import nl.vu.few.ibivu.biomodels.client.place.MyModelsBrowsingPlace;
import nl.vu.few.ibivu.biomodels.client.place.ModelPlace;
import nl.vu.few.ibivu.biomodels.client.place.PreferencesViewPlace;
import nl.vu.few.ibivu.biomodels.client.place.WelcomePlace;
import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;
import com.google.inject.Inject;
import com.google.inject.Provider;

public class MainActivityMapper implements ActivityMapper {
	
	@Inject Provider<WelcomeActivity> welcomeActivityProvider;
	@Inject Provider<ModelActivity> modelActivityProvider;
	@Inject Provider<ModelBrowsingActivity> modelBrowsingActivityProvider;
	@Inject Provider<PreferencesBrowsingActivity> preferencesBrowsingActivityProvider;
	
	@Override
	public Activity getActivity(Place place) {
		if (place instanceof WelcomePlace) {
			return welcomeActivityProvider.get();
		}
		if (place instanceof ModelPlace) {
			return modelActivityProvider.get().withPlace((ModelPlace) place);
        }
		if (place instanceof MyModelsBrowsingPlace) {
			return modelBrowsingActivityProvider.get();
        }
		if (place instanceof PreferencesViewPlace) {
			return preferencesBrowsingActivityProvider.get();
		}
        return null;
	}

}
